package com.slz3.business.module.memberManagement.memShoppingCar.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.memberManagement.memShoppingCar.domain.MemShoppingCar;
import com.slz3.business.module.memberManagement.memShoppingCar.domain.MemShoppingCarFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class MemShoppingCarTransactionalServiceImpl implements MemShoppingCarTransactionalService {

    @Override
    public MemShoppingCar modify(MemShoppingCar memShoppingCarNew) {
        Repositorys.memShoppingCar.test();
        Repositorys.memShoppingCar.save(MemShoppingCarFactory.initBaseFields());
        System.err.println(1/0);
        memShoppingCarNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.memShoppingCar.saveAndFlush(memShoppingCarNew);
    }

    @Override
    public List<MemShoppingCar> batchModify(List<MemShoppingCar> memShoppingCarList) {
        return Repositorys.memShoppingCar.saveAll(memShoppingCarList);
    }
}
